﻿Public Class frmTabAccess
    Public Shared objDataContact As ContactInfo = New ContactInfo()
    Dim editNode As EditXML = New EditXML()
    Public Shared sPdelim As String = "£"

    Private Sub txtIDaccess_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIDaccess.Leave
        editXMLFile()
    End Sub

    Private Sub txtIDuse_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIDuse.Leave
        editXMLFile()
    End Sub

    Private Sub txtDataSecSys_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDataSecSys.Leave
        editXMLFile()
    End Sub

    Private Sub txtDataSecDesc_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDataSecDesc.Leave
        editXMLFile()
    End Sub

    Private Sub frmTabAccess_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Leave
        editXMLFile()
    End Sub

    Public Sub editXMLFile()
        editNode.Edit("/metadata/idinfo/accconst", txtIDaccess.Text.Trim())
        editNode.Edit("/metadata/idinfo/useconst", txtIDuse.Text.Trim())
        editNode.Edit("/metadata/idinfo/secinfo/secsys", txtDataSecSys.Text.Trim())
        editNode.Edit("/metadata/idinfo/secinfo/secclass", cboxDataSecClass.SelectedItem)
        editNode.Edit("/metadata/idinfo/secinfo/sechandl", txtDataSecDesc.Text.Trim())
        If txtDataContact.Text.Trim() <> "" Then
            editNode.Remove("/metadata/idinfo", "ptcontac")
            Dim newNode As String = editNode.createContactInfo(objDataContact)
            editNode.Add("/metadata/idinfo", "/secinfo", "ptcontac", newNode)
        End If
    End Sub

    Private Sub btnDataContact_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDataContact.Click
        Dim iConType As Integer = 0
        Dim frmDataCont As frmContact
        If (txtDataContact.Text = "") Then
            frmDataCont = New frmContact(objDataContact, 1)
        Else
            frmDataCont = New frmContact(objDataContact, 2)
        End If
        frmDataCont.ShowDialog()
        If (frmDataCont.getUpdated() = True) Then
            objDataContact = frmDataCont.getConInfo() 'update the contact object
            If (objDataContact.PrimaryPerson = True) Then 'update the form display
                txtDataContact.Text = objDataContact.Person
            Else
                txtDataContact.Text = objDataContact.Organization
            End If
        End If
    End Sub

    Private Sub button_example_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button_example.Click
        Dim helpForm As dialog_help = New dialog_help("Access")
        helpForm.ShowDialog()
    End Sub
End Class